//
//  imagePickViewController.m
//  jiajiao
//
//  Created by apple on 16/4/14.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "imagePickViewController.h"

@interface imagePickViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property(nonatomic,strong)UIImagePickerController *pickcoller;
@end

@implementation imagePickViewController
-(UIImagePickerController *)pickcoller
{
    if (!_pickcoller) {
        _pickcoller=[[UIImagePickerController alloc]init];
        _pickcoller.delegate =self;
    }
    return _pickcoller;
}
- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)typedeimageview:(UIImagePickerControllerSourceType )type
{
    UIWindow *window =  [UIApplication sharedApplication].keyWindow;
    [window addSubview:self.view];
    self.pickcoller.sourceType = type;
    self.modalPresentationStyle=UIModalPresentationOverCurrentContext;
    [self presentViewController:self.pickcoller animated:YES completion:nil];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
    UIImage  *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    self.block (image);
    [self dismissViewControllerAnimated:NO completion:^{
        [self.view removeFromSuperview];

    }];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:NO completion:^{
        [self.view removeFromSuperview];
        
    }];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
